package com.sg.service.biz.app.nb;

import cn.hutool.core.bean.BeanUtil;
import com.sg.common.util.CommonFunctionHelper;
import com.sg.dto.biz.app.req.ImplementBizPublicFieldPushMemoryReqDto;
import com.sg.dto.biz.app.req.ImplementFourthReceivingFieldReqDto;
import com.sg.dto.biz.app.req.ImplementSendMsgReceiverAcceptFieldReqDto;
import com.sg.dto.biz.app.req.ObtainReceiveOutFieldReqDto;
import com.sg.dto.biz.app.res.ImplementBizPublicFieldPushMemoryRespDto;
import com.sg.dto.biz.app.res.ImplementFourthReceivingFieldRespDto;
import com.sg.dto.biz.app.res.ImplementSendMsgReceiverAcceptFieldRespDto;
import com.sg.dto.biz.app.res.ObtainReceiveOutFieldRespDto;
import com.wicket.okrapp.common.baseinfo.BaseInfoDO;
import com.wicket.okrapp.common.baseinfo.BaseInfoHolder;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

/**
 * @author ： 手工接入方法
 * @version 1.0
 * @since 2022/5/28 15:32
 */
@Service
public class NbCommunication {
    /**
     * code:receptionService
     * name:M3用于接收数据集入参
     * desc:undefined
     * gen by moon at 1/26/2024, 4:46:57 AM
     **/
    @Trace(operationName = "M3用于接收数据集入参")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementFourthReceivingFieldRespDto implementFourthReceivingField(ImplementFourthReceivingFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementFourthReceivingFieldRespDto.class);
    }

    /**
     * code:publicFieldCache
     * name:M3执行业务应用公共字段推送内存（特殊方法）
     * desc:undefined
     * gen by moon at 1/26/2024, 4:47:28 AM
     **/
    @Trace(operationName = "M3执行业务应用公共字段推送内存（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementBizPublicFieldPushMemoryRespDto implementBizPublicFieldPushMemory(ImplementBizPublicFieldPushMemoryReqDto reqDto) {
        BaseInfoDO domain = new BaseInfoDO();
        if (BaseInfoHolder.contextHolder.get() != null) {
            BeanUtil.copyProperties(BaseInfoHolder.contextHolder.get().getBaseInfo(), domain);
            BaseInfoHolder.contextHolder.remove();
        }
        if (reqDto.getSpaceId() != null) {
            domain.setSpecSpaceId(reqDto.getSpaceId());
        }

        if (reqDto.getCreateInductionId() != null) {
            domain.setSpecInductionRecordId(reqDto.getCreateInductionId());
        }

        if (reqDto.getAppId() != null) {
            domain.setSpecAppId(reqDto.getAppId());
        }

        if (reqDto.getHighestOrgID() != null) {
            domain.setSpecHighestOrgID(reqDto.getHighestOrgID());
        }

        if (reqDto.getUserId() != null) {
            domain.setSpecUserId(reqDto.getUserId());
        }

        if (reqDto.getOriginalRoleMemberId() != null) {
            domain.setSpecOriginalRoleMemberId(reqDto.getOriginalRoleMemberId());
        }

        CommonFunctionHelper.setBaseInfoToLocal(domain);
        return new ImplementBizPublicFieldPushMemoryRespDto();
    }

    /**
     * code:receptionService
     * name:M3约定高中基层回退操作消息模板标识
     * desc:undefined
     * gen by moon at 2/13/2024, 10:42:55 AM
     **/
    @Trace(operationName = "M3约定高中基层回退操作消息模板标识")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ObtainReceiveOutFieldRespDto obtainReceiveOutField(ObtainReceiveOutFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ObtainReceiveOutFieldRespDto.class);

    }

    /**
     * code:receptionService
     * name:M3接收字段
     * desc:undefined
     * gen by moon at 2/13/2024, 10:43:12 AM
     **/
    @Trace(operationName = "M3接收字段")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementSendMsgReceiverAcceptFieldRespDto implementSendMsgReceiverAcceptField(ImplementSendMsgReceiverAcceptFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementSendMsgReceiverAcceptFieldRespDto.class);
    }
    //手工接入方法
}
